import { createRouter, createWebHistory } from 'vue-router';
import HomeView from '../views/HomeView.vue';

const routes = [
  // 大型项目，页面多，80% 页面不常用，可以使用懒加载的方式，
  // 减少编译后文件的大小，提高初始访问速度；
  // 小项目，页面少，可以用静态导入的方式，对编译后的文件大小影响不大
  {
    // 静态导入
    path: '/',
    name: 'home',
    component: HomeView,
  },
  {
    // 懒加载
    path: '/about',
    name: 'about',
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue'),
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login.vue'),
  },
];

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
});

export default router;
